package com.jumeng.controller;


import com.jumeng.server.WxUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController("/api/user")
@Api(tags = "用户接口")
@Slf4j
public class UserController {

    @Autowired
    private WxUserService wxUserService;


    @GetMapping("/getPromotionCode")
    @ApiOperation("获取主推荐人的推广码")
    public String getPromotionCode(@RequestParam("openId") String openId) {
        return wxUserService.getPromotionCode(openId);
    }

    @GetMapping("/fillInPromotionCode")
    @ApiOperation("被推荐人填写推广码")
    public Boolean fillInPromotionCode(@RequestParam("openId") String openId, @RequestParam("promotionCode") String promotionCode) {
        return wxUserService.fillInPromotionCode(openId, promotionCode);
    }
}
